//to logout
jQuery(document).ready(function(){    
    jQuery("#logout").on("click", function(event){
        event.preventDefault();
        jQuery.ajax({
            scriptCharset: 'utf-8',
            type: "POST",
            url: "/logout",
            contentType: "application/json",
            data: JSON.stringify({
                "uid": document.cookie.split(';')[0].split('=')[1],
                "phonenumber": document.cookie.split(';')[1].split('=')[1]
            }),
            dataType: "json",
            success: function(result) {
                //alert("success sent data");
                if(result.errorcode==1){
                    //alert(result.errormessage);
                    window.location.href="/";
                }
                if(result.errorcode==0){
                    //alert(result.errormessage+"XXX");
                }
            },
            error: function(error) {
                //alert("Erro : not logout");
            }
        });
    });
});

